//
//  UIView+ Extension.swift
//  新浪微博
//
//  Created by 朱玉龙 on 16/10/6.
//  Copyright © 2016年 朱玉龙. All rights reserved.
//

import UIKit

extension UIView {
    
    func getCurrentScreenImage() -> UIImage {
        
        let window = UIApplication.shared.keyWindow
        
        UIGraphicsBeginImageContextWithOptions((window!.bounds.size), false, UIScreen.main.scale)
        
        window?.drawHierarchy(in: window!.bounds, afterScreenUpdates: false)
        
        let image = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        
        return image!
    }
    
    
    var cornerRadius:CGFloat {
        set {
            layer.cornerRadius = newValue
            layer.masksToBounds = newValue > 0
        }
        get {
            
            return layer.cornerRadius
        }
        
    }
    
    
}
